<?php

declare (strict_types=1);
namespace App\Model;

use App\Traits\ModelLabelTrait;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model;
use mysql_xdevapi\Exception;

/**
 * @property int $id 
 * @property int $material_id 
 * @property int $data_id 
 * @property int $type 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class MaterialAssign extends Model
{
    use SoftDeletes,ModelLabelTrait;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'material_assign';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'type',
        'material_id',
        'data_id',
        'status'
    ];

    protected $appends = [
        'status_label'
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'material_id' => 'integer', 'data_id' => 'integer', 'type' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    const TYPE_ONE = 1;
    const TYPE_TWO = 2;
    const TYPE_THREE = 3;

    const TYPE_LABELS=[
        self::TYPE_ONE => '区县',
        self::TYPE_TWO => '街道',
        self::TYPE_THREE => '社区'
    ];

    const STATUS_DEFAULT = 0;
    const STATUS_ISUPLOAD = 1;
    const STATUS_WAITVERIRY = 10;
    const STATUS_VERIFY =20;
    const STATUS_VERIFYSUCCESS = 21;
    const STATUS_VERIFYFAIL = 22;
    const STATUS_SCORE = 30;

    const STATUS_LABELS = [
        self::STATUS_DEFAULT => '待上传',
        self::STATUS_ISUPLOAD => '待上报',
        self::STATUS_WAITVERIRY => '待审核',
        self::STATUS_VERIFY => '审核中',
        self::STATUS_VERIFYSUCCESS => '审核通过',
        self::STATUS_VERIFYFAIL => '打回',
        self::STATUS_SCORE => '已打分'
    ];

    public function getStatusLabelAttribute(){
        return self::getLabel('status',$this->status);
    }
}